define(["app", "comm/js/services/BaseService"], function (app, BaseService) {

    var deps = ["$http", "BaseService"];

    function fileuploadResource ($http, BaseService) {
        return initResource($http, BaseService.restfulUrl + "tempFileUploadController/");
    }

    var headers = {
        "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
    };

    function initResource ($http, fileuploadUrl) {
        return {
            /**
             * 获取附件列表
             * @param taskId 任务Id
             */
            upload: function (taskId) {
                return $http.get(fileuploadUrl + "getTaskAttachs", {
                    params: {
                        taskId: taskId
                    }
                });
            },

            /**
             * 删除附件
             * @param prop 附件关联ID类型名称
             * @param objId ID值
             * @param fileIds 文件ID集
             */
            delAttachs: function (prop, objId, fileIds) {
                return $http.post(fileuploadUrl + "delAttachs", {
                    prop: prop,
                    objId: objId,
                    fileIds: fileIds
                }, {
                    headers: headers
                });
            }
        };
    }

    fileuploadResource.$inject = deps;
    return app.lazy.service("FileuploadResource", fileuploadResource);
});